Skip to content

fix(discovery): resolve Claude desktop sessions with parent-directory CWD#131

Merged
z0w0 merged 1 commit intomainfrom
fix/session-discovery-gaps
Apr 2, 2026
Merged

fix(discovery): resolve Claude desktop sessions with parent-directory CWD#131
z0w0 merged 1 commit intomainfrom
fix/session-discovery-gaps

Conversation

@songcarver
Copy link
Copy Markdown
Contributor

Summary

  • When the Claude desktop app creates a session, the manifest's cwd often points to a parent directory (e.g. ~/Documents/GitHub) rather than the specific repo. Since that directory isn't a git repo, the session is silently skipped and the repo never appears on the dashboard.
  • Adds a transcript-scanning fallback: when CWD resolution fails, reads the session's JSONL transcript, extracts absolute file paths from tool-call inputs (file_path, path, directory, cd commands), and resolves the first candidate to a git repo root.
  • Applied in both the backfill loop and background monitor tick path.

Safety bounds

  • Max 20 candidate directories tried (caps git subprocess calls)
  • Max 16 levels of JSON nesting (prevents stack overflow)
  • Skips output/result/text fields (avoids noise from command output)
  • Only absolute paths considered (relative paths filtered out)

Test plan

  • 9 unit tests covering path extraction, deduplication, cd parsing, edge cases
  • Local end-to-end: created Claude desktop manifest with parent-dir CWD, production binary skipped it (repo_root_lookup_failed), patched binary resolved it from transcript and uploaded (CLI-Repo-test appeared on backfill)
  • cargo fmt, cargo clippy, cargo test all pass (609 tests)
  • CI passes

🤖 Generated with Claude Code

… CWD

When the Claude desktop app launches a session, the manifest's `cwd`
often points to a parent directory (e.g. ~/Documents/GitHub) rather
than the specific repo. Since that directory isn't a git repo,
`resolve_repo_root_with_fallbacks` fails and the session is silently
skipped, leaving the repo invisible on the Cadence dashboard.

Add a transcript-scanning fallback: when CWD resolution fails, read
the session's JSONL transcript and extract absolute file paths from
tool-call inputs (file_path, path, directory fields) and cd commands.
Try each candidate directory against git rev-parse until a repo root
is found.

Safety bounds:
- Max 20 candidate directories tried (caps git subprocess calls)
- Max 16 levels of JSON nesting (prevents stack overflow)
- Skips output/result/text fields (avoids noise from command output)
- Only absolute paths considered (relative paths filtered out)

The fallback is wired into both the backfill loop and the background
monitor tick path.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown

@cadence cadence bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cadence PR Review

Goal
Add a bounded fallback for Claude desktop session discovery when the manifest cwd points to a parent directory, by scanning transcripts for absolute path hints and using that in both backfill and monitor flows. The intent was to close only the Claude desktop gap, not reopen broader session-discovery changes.

Signal Details
Score A- strong scope alignment and verification
Models claude-opus-4-6
Phases 25% scoping, 55% implementation, 20% verification

Key Decisions

  • The user explicitly narrowed scope to Gap 3 only: Claude desktop parent-directory cwd fallback.
  • The model chose a transcript-based recovery strategy with hard safety bounds on candidate count and JSON traversal depth.
  • The user and model verified the change with targeted transcript-parsing tests plus a full Rust test/clippy/fmt pass before pushing.

Outcome

The model stayed well aligned with the stated PR goal and implemented the fallback in the two paths called out in the PR. The main weakness is a bit of duplicated fallback logic across code paths, which suggests the user accepted a working patch without pushing the model to consolidate the shared behavior.

Recommendations

Prompting  Prompt for shared logic

For multi-path behavior changes, explicitly ask the model to centralize shared logic. That makes it easier to review requirement coverage and catch drift between backfill and monitor behavior.

Reframe

"Implement this fallback in both discovery paths through one shared helper, and list any unavoidable divergences."

If this review was useful, please react with 👍 below. Otherwise, react with 👎.

@z0w0 z0w0 merged commit 99f4fcd into main Apr 2, 2026
3 checks passed
@z0w0 z0w0 deleted the fix/session-discovery-gaps branch April 2, 2026 07:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants